

package com.hexinfo.dmpro.demo.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.http.ResponseEntity;
import com.hexinfo.dmpro.demo.model.TTest;
import com.hexinfo.dmpro.demo.service.TTestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 测试表
 *
 * @author yemw
 * @date 2023-08-08 09:54:22
 */
@RestController
@AllArgsConstructor
@RequestMapping("/ttest" )
@Api(value = "ttest", tags = "测试表管理")
public class TTestController {

    private final  TTestService tTestService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param tTest 测试表
     * WrapperEnhancer.like(tTest); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public ResponseEntity<Object> getTTestPage(Page page, TTest tTest) {
        return ResponseEntity.ok(tTestService.queryList(page,tTest));
    }


    /**
     * 通过id查询测试表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public ResponseEntity<Object> getById(@PathVariable("id" ) String id) {
        return ResponseEntity.ok(tTestService.getById(id));
    }

    /**
     * 新增测试表
     * @param tTest 测试表
     * @return R
     */
    @ApiOperation(value = "新增测试表", notes = "新增测试表")
    @PostMapping
    public ResponseEntity<Object> save(@RequestBody TTest tTest) {
        return ResponseEntity.ok(tTestService.save(tTest));
    }

    /**
     * 修改测试表
     * @param tTest 测试表
     * @return R
     */
    @ApiOperation(value = "修改测试表", notes = "修改测试表")
    @PutMapping
    public ResponseEntity<Object> updateById(@RequestBody TTest tTest) {
        return ResponseEntity.ok(tTestService.updateById(tTest));
    }

    /**
     * 通过id删除测试表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除测试表", notes = "通过id删除测试表")
    @DeleteMapping("/{id}" )
    public ResponseEntity<Object> removeById(@PathVariable String id) {
        return ResponseEntity.ok(tTestService.removeById(id));
    }

}
